package com.example.datamanage.controller;

import com.example.datamanage.common.Result;
import com.example.datamanage.pojo.Gather;
import com.example.datamanage.service.GatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 28142
 * @description 采集数据 控制层
 * @date 2023/8/1 9:19
 */
@RestController
@RequestMapping("/gather")
public class GatherController {
    @Autowired
    private GatherService gatherService;

    /* @GetMapping
    public Result findPage(@RequestParam(required = false) String chName,
                           @RequestParam(required = false) String enName,
                           @RequestParam(required = false) String gatherTime,
                           @RequestParam(required = false) int status) {

        return gatherService.findPage(pageNum, pageSize, gatherTime, status);
        // return Result.success();
    } */

    @GetMapping("/")
    public Result findTablesByGather(
            @PathVariable Integer datasource,
            @RequestParam(required = false) String chName,
            @RequestParam(required = false) String enName,
            @RequestParam(required = false) String gatherTime) {
        return gatherService.findTablesByGather(datasource, chName, enName, gatherTime);
    }

    @PostMapping
    public Result addRecord(@RequestBody Gather gather) {
        System.out.println(gather);
        return gatherService.save(gather) ? Result.success() : Result.error();
    }
}
